package ch8;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Money {
    public static void main(String[] args) {
        //人民币的组合方式

        int cout = 0;
        int a1 = 1;
        int a2 = 2;
        int a5 = 5;
        int a10 = 10;
        int a20 = 20;
        int a50 = 50;
        int a100 = 100;
        System.out.println("请输入一个正整数的金额");
        Scanner in = new Scanner(System.in);
        int z = in.nextInt();
        for (int b1 = 0; b1 <= z; b1++) {
            for (int b2 = 0; b2 <= (z / 2); b2++) {
                for (int b3 = 0; b3 <= (z / 5); b3++) {
                    for (int b4 = 0; b4 <= (z / 10); b4++) {
                        for (int b5 = 0; b5 <= (z / 20); b5++) {
                            for (int b6 = 0; b6 <= (z / 50); b6++) {
                                for (int b7 = 0; b7 <= (z / 100); b7++) {
                                    if ((a1 * b1 + a2 * b2 + a5 * b3 + a10 * b4 + a20 * b5 + a50 * b6 + a100 * b7) == z) {
                                        cout++;
                                        System.out.println("方案" + cout + ":" + b1 + "个1元 " + b2 + "个2元 " + b3 + "个5元 " + (b4==0?"":(b4 + "个10元 ")) + b5 + "个20元 " + b6 + "个50元 " + b7 + "个100元");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


